package 算法.leetcode.offer;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author lchenglong
 * @date 2022/3/18
 */
public class Offer50 {

    public static void main(String[] args) {
        Offer50 instance = new Offer50();
        char c = instance.firstUniqChar("leetcode");
        System.out.println(c);
    }
    public char firstUniqChar(String s) {
        Map<Character,Integer> map = new LinkedHashMap<Character, Integer>();
        for (int i=0,len = s.length();i<len;i++){
            map.put(s.charAt(i),map.get(s.charAt(i))==null?1:2);
        }
        for (Map.Entry<Character,Integer> entry: map.entrySet()){
            if (entry.getValue()==1){
                return entry.getKey();
            }
        }
        return ' ';
    }
}
